﻿// JavaScript Document

function startMove(obj,json,endFn){
	
		clearInterval(obj.timer);
		
		obj.timer = setInterval(function(){
			
			var bBtn = true;
			
			for(var attr in json){
				
				var iCur = 0;
			
				if(attr == 'opacity'){
					if(Math.round(parseFloat(getStyle(obj,attr))*100)==0){
					iCur = Math.round(parseFloat(getStyle(obj,attr))*100);
					
					}
					else{
						iCur = Math.round(parseFloat(getStyle(obj,attr))*100) || 100;
					}	
				}
				else{
					iCur = parseInt(getStyle(obj,attr)) || 0;
				}
				
				var iSpeed = (json[attr] - iCur)/8;
			iSpeed = iSpeed >0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
				if(iCur!=json[attr]){
					bBtn = false;
				}
				
				if(attr == 'opacity'){
					obj.style.filter = 'alpha(opacity=' +(iCur + iSpeed)+ ')';
					obj.style.opacity = (iCur + iSpeed)/100;
					
				}
				else{
					obj.style[attr] = iCur + iSpeed + 'px';
				}
				
				
			}
			
			if(bBtn){
				clearInterval(obj.timer);
				
				if(endFn){
					endFn.call(obj);
				}
			}
			
		},30);
	
	}
	
	
	function getStyle(obj,attr){
		if(obj.currentStyle){
			return obj.currentStyle[attr];
		}
		else{
			return getComputedStyle(obj,true)[attr];
		}
	}


$(function(){
/*****************************************焦点图 ------1   开始********************************************/
/************焦点图介绍：鼠标移上图片直接显示*************/
	/****获取轮播内容对象****/
	var focusCarousel_ul1=$('.focusCarousel_ul1');
	var focusCarousel_li1=$('.focusCarousel_li1');

	/****获取小标签对象****/
	var focusCarousel_ol1=$('.focusCarousel_ol1');
	var focusCarousel_ol_li1=$('.focusCarousel_ol1 li');
	
	for (var i = 0; i < focusCarousel_ol_li1.length; i++) {
		/****给小标签的角标赋值****/
		focusCarousel_ol_li1[i].index=i;
		/***鼠标移上小标签***/
		focusCarousel_ol_li1[i].onmouseover=function(){
			/***按钮样式的切换***/
			/*****把所有的小标签的样式都变为鼠标移下的样式****/
			for (var i = 0; i < focusCarousel_ol_li1.length; i++) {
				focusCarousel_ol_li1[i].className="";
				/***隐藏所有的内容***/
				focusCarousel_li1[i].style.display='none'
			}
			/***鼠标移上的小标签变样式**/
			this.className='focus_active1';
			/***显示鼠标移上的小标签代表的内容***/
			focusCarousel_li1[this.index].style.display='block';
		}
	};


/*****************************************焦点图 ------1   结束********************************************/



/*****************************************焦点图 ------2   开始********************************************/
/************焦点图介绍：鼠标移上图片直接显示*************/
	/****获取轮播内容对象****/
	var focusCarousel_ul2=$('.focusCarousel_ul2');
	var focusCarousel_li2=$('.focusCarousel_li2');

	/****获取小标签对象****/
	var focusCarousel_ol2=$('.focusCarousel_ol2');
	var focusCarousel_ol_li2=$('.focusCarousel_ol2 li');
	
	for (var i = 0; i < focusCarousel_ol_li2.length; i++) {
		/****给小标签的角标赋值****/
		focusCarousel_ol_li2[i].index=i;
		/***鼠标移上小标签***/
		focusCarousel_ol_li2[i].onmouseover=function(){
			/***按钮样式的切换***/
			/*****把所有的小标签的样式都变为鼠标移下的样式****/
			for (var i = 0; i < focusCarousel_ol_li2.length; i++) {
				focusCarousel_ol_li2[i].className="";
				/***隐藏所有的内容***/
				focusCarousel_li2[i].style.display='none';
				focusCarousel_li2[i].style.filter='alpha(opacity=0)';
				focusCarousel_li2[i].style.opacity=0;
			}
			/***鼠标移上的小标签变样式**/
			this.className='focus_active2';
			/***显示鼠标移上的小标签代表的内容***/
			focusCarousel_li2[this.index].style.display='block';
			startMove(focusCarousel_li2[this.index],{opacity:100});
		}
	};


/*****************************************焦点图 ------2  结束********************************************/

/*****************************************焦点图 ------3   开始********************************************/
/************焦点图介绍：鼠标移上图片直接显示*************/
	/****获取轮播内容对象****/
	var focusCarousel_ul3=$('.focusCarousel_ul3');
	var focusCarousel_li3=$('.focusCarousel_li3');

	/****获取小标签对象****/
	var focusCarousel_ol3=$('.focusCarousel_ol3');
	var focusCarousel_ol_li3=$('.focusCarousel_ol3 li');
	
	for (var i = 0; i < focusCarousel_ol_li3.length; i++) {
		/****给小标签的角标赋值****/
		focusCarousel_ol_li3[i].index=i;
		/***鼠标移上小标签***/
		focusCarousel_ol_li3[i].onmouseover=function(){
			/***按钮样式的切换***/
			/*****把所有的小标签的样式都变为鼠标移下的样式****/
			for (var i = 0; i < focusCarousel_ol_li3.length; i++) {
				focusCarousel_ol_li3[i].className="";
				
				startMove(focusCarousel_li3[i],{opacity:0},function(){
						this.style.display='none';
				});
			}
			/***鼠标移上的小标签变样式**/
			this.className='focus_active3';
			/***显示鼠标移上的小标签代表的内容***/
			focusCarousel_li3[this.index].style.display='block';
			startMove(focusCarousel_li3[this.index],{opacity:100});
		}
	};


/*****************************************焦点图 ------3  结束********************************************/



/*****************************************焦点图 ------5   开始********************************************/
/************焦点图介绍：鼠标移上图片直接显示*************/
	/****获取轮播内容对象****/
	var focusCarousel_ul5=$('.focusCarousel_ul5');
	var focusCarousel_li5=$('.focusCarousel_li5');

	/****获取小标签对象****/
	var focusCarousel_ol5=$('.focusCarousel_ol5');
	var focusCarousel_ol_li5=$('.focusCarousel_ol5 li');

	/**这是第几张图片**/
	var iNow=0;

	/***时间***/
	var timer=null;

	/****获取最外边的盒子*****/
	var focusCarousel_box5=$('#focusCarousel_box5');
	for (var i = 0; i < focusCarousel_ol_li5.length; i++) {
		/****给小标签的角标赋值****/
		focusCarousel_ol_li5[i].index=i;
		/***鼠标移上小标签***/
		focusCarousel_ol_li5[i].onmouseover=function(){
			/***按钮样式的切换***/
			/*****把所有的小标签的样式都变为鼠标移下的样式****/
			for (var i = 0; i < focusCarousel_ol_li5.length; i++) {
				focusCarousel_ol_li5[i].className="";
				
				startMove(focusCarousel_li5[i],{opacity:0},function(){
						this.style.display='none';
				});
			}
			/***鼠标移上的小标签变样式**/
			this.className='focus_active5';
			iNow=this.index;
			/***显示鼠标移上的小标签代表的内容***/
			focusCarousel_li5[this.index].style.display='block';
			startMove(focusCarousel_li5[this.index],{opacity:100});
		}
	};

	timer=setInterval(toRun,2000);

	focusCarousel_box5.mouseover(function(){
		clearInterval(timer);
	});
	focusCarousel_box5.mouseout(function(){
		timer=setInterval(toRun,2000);
	});
	function toRun(){
			if(iNow==focusCarousel_ol_li5.length-1)	{
				iNow=0;
			}else{
				iNow++;	
				}
				for (var i = 0; i < focusCarousel_ol_li5.length; i++) {
					focusCarousel_ol_li5[i].className="";
					startMove(focusCarousel_li5[i],{opacity:0},function(){
							this.style.display='none';
					});
				}
				/***鼠标移上的小标签变样式**/
				focusCarousel_ol_li5[iNow].className='focus_active5';
				/***显示鼠标移上的小标签代表的内容***/
				focusCarousel_li5[iNow].style.display='block';
				startMove(focusCarousel_li5[iNow],{opacity:100});
			
	}
/*****************************************焦点图 ------5  结束********************************************/

});

